function maxProfit(prices: number[]): number {
  let sum: number = 0;
  for (let i = 0; i < prices.length - 1; i++) {
    for (let j = i + 1; j < prices.length; j++) {
      if (prices[j] - prices[i] > sum) {
        sum = prices[j] - prices[i];
      }
    }
  }
  return sum;
}
console.log(maxProfit([7, 1, 5, 3, 6, 4]));
